package com.SunSoft.PhoneRemoteControl;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;

final class aj extends BroadcastReceiver
{
  public final void onReceive(Context paramContext, Intent paramIntent)
  {
    int i = 1;
    if (paramIntent.hasExtra("state"))
    {
      if (paramIntent.getIntExtra("state", 0) != 0)
        break label133;
      MainControl.a("Test", "耳机断开");
      MyApplication.a().a = false;
      if (MyApplication.a().d)
        MyApplication.a().e = true;
      if ((!(MyApplication.a().d)) && (MyApplication.a().c))
        MyApplication.a().d = true;
      if (MyApplication.a().g)
      {
        MyApplication.a().e = false;
        MyApplication.a().d = false;
      }
      paramContext = new Message();
      paramContext.what = 27;
      this.a.ca.sendMessage(paramContext);
      MyApplication.a().g = false;
    }
    return;
    label133: MainControl.a("Test", "耳机接入");
    MyApplication.a().a = true;
    paramContext = MyApplication.a();
    if (paramIntent.getIntExtra("microphone", 0) > 0)
    {
      paramContext.b = i;
      MyApplication.a().e = false;
      MyApplication.a().c = false;
      MyApplication.a().f = false;
      MyApplication.a().d = false;
      if (!(MyApplication.a().b))
        break label381;
      MainControl.d(this.a).a("is_has_mic", "1");
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          do
          {
            do
            {
              MainControl.d(this.a).a("is_soft_disconnect", "0");
              MainControl.a("Test", "is_handset_connected:" + String.valueOf(MyApplication.a().a));
              MainControl.a("Test", "name:" + paramIntent.getStringExtra("name"));
              MainControl.a("Test", "is_has_mic:" + String.valueOf(MyApplication.a().b));
            }
            while (MainControl.b(this.a) != 0);
            paramContext = new Message();
            paramContext.what = 25;
            this.a.ca.sendMessage(paramContext);
          }
          while ((MainControl.e) || (MyApplication.a().c));
          MainControl.a(this.a);
        }
        i = 0;
      }
      label381: MainControl.d(this.a).a("is_has_mic", "0");
    }
  }
}